package netWork;
import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class EnglishServer  extends UdpServer{
    //创建一个哈希表
    private Map<String,String> dict = new HashMap<>();

    public EnglishServer(int port) throws SocketException {
        super(port);

        //向哈希表中添加元素
        dict.put("dog", "小狗");
        dict.put("cat", "小猫");
        dict.put("pig", "小猪");


    }

    //2: 重写process方法，在重写的process方法中完成翻译的过程
    @Override
    public String process(String request){
        return dict.getOrDefault(request,"该词在词典中不存在");

    }

    public static void main(String[] args) throws IOException {
        EnglishServer server = new EnglishServer(9090);
        ////调用父类UdpServer的start方法
        server.start();

    }

}
